---
title: "Supplementary Information for 'The Impact of Real World Information Shocks on Political Attitudes: Evidence from the Panama Papers Disclosures'"
author: 
date: "March 2022"
output:
  pdf_document:
    number_sections: yes
urlcolor: magenta
header-includes: \usepackage{booktabs} \usepackage{float} \floatplacement{figure}{H}
  \floatplacement{table}{H} \usepackage[bottom]{footmisc}
editor_options: 
  chunk_output_type: console
---

```{r setup, include=FALSE}
library(tidyverse)
library(ggrepel)
library(cowplot)
library(scales)
library(haven)
library(here)
library(stargazer)
library(lubridate)
library(margins)
library(kableExtra)
library(summarytools)
library(hrbrthemes) 
library(psych)
  extrafont::loadfonts() 
  theme_set(theme_ipsum_rc()) 

knitr::opts_chunk$set(echo = FALSE,warning = FALSE, message=FALSE,
                      fig.width = 8,fig.align="center",
                      tidy.opts=list(width.cutoff=80),tidy=TRUE)  


# No scientific notation 
 options(scipen=999)
 
# Make dplyr default
 select <- dplyr::select
 filter <- dplyr::filter
 here <- here::here
```

```{r pdf, eval=knitr::is_latex_output()}
 knitr::opts_chunk$set(dev="cairo_pdf")  

```

This file contains supplementary information for the paper, as well as the code required to perform the main analysis in the paper itself. We are grateful to the authors of Larsen, Cutts and Goodwin (2020) for providing well documented code for the same research design - some of our code below is inspired by their approach.[^1]

[^1]: Larsen, E.G., Cutts, D. and Goodwin, M.J. (2020), Do terrorist attacks feed populist Eurosceptics? Evidence from two comparative quasi-experiments. *European Journal of Political Research*, 59: 182-205. doi:10.1111/1475-6765.12342

# Data
Both survey datasets used in the analysis are subject to restrictions on dissemination to third parties and as a consequence cannot be provided as part of the replication materials. However, the data are freely available to individuals signing the terms of usage of the respective data distributors.[^2][^3]

[^2]: ISSP Research Group (2018): International Social Survey Programme: Role of Government V - ISSP 2016. GESIS Data Archive, Cologne. ZA6900 Data file Version 2.0.0, <doi:10.4232/1.13052>.

[^3]: Centro de Investigaciones Sociológicas. (2016). Study Nr. 3134: April 2016 Barometer.  [Retrieved from CIS website](http://www.cis.es/cis/opencm/ES/1_encuestas/estudios/ver.jsp?estudio=14277). 

```{r france-dataprep, cache=TRUE}
 # Load primary data

 france = read_sav(here("ROG2016.sav")) %>% filter(country==250)

# Create treatment indicators
 france = france %>% mutate(date=ymd(paste(DATEYR,DATEMO,DATEDY,sep="-")),
                            treat_full=case_when(date < (ymd("2016-04-03")) ~ 0,
                                            date > (ymd("2016-04-03")) ~ 1),
                            treat_1month=case_when(date < (ymd("2016-04-03")) &  
                                            date > (ymd("2016-04-03") %m-% months(1)) ~ 0,
                                            date > (ymd("2016-04-03")) & 
                                            date < (ymd("2016-04-03") %m+% months(1)) ~ 1))

# Recode covariates
 france = france %>% mutate(female=case_when(SEX==1~0, 
                                             SEX==2~1),
                            age=ifelse(AGE>14 & AGE<100, AGE, NA),
                            educyrs=case_when(EDUCYRS < 21 ~ EDUCYRS,
                                              EDUCYRS > 20 ~ 21),
                            tertiary=ifelse(DEGREE>4,1,0),
                            union=case_when(UNION==1 ~ 1,
                                            UNION %in% c(2,3) ~ 0),
                            churchattend_never=case_when(ATTEND==8 ~ 1,
                                            TRUE ~ 0),
                            unemployed = case_when(MAINSTAT==2 ~ 1,
                                                   TRUE ~ 0),
                            retired = case_when(MAINSTAT==6 ~ 1,
                                                TRUE ~ 0),
                            paidwork = case_when(MAINSTAT==1 ~ 1,
                                                TRUE ~ 0),
                            hhinc = (FR_INC/1000),
                            hhinceq = hhinc/sqrt(HOMPOP),
                            top40=ifelse(hhinceq>2.5,1,0)) 

# Create indicator variable for missingness on income
 france$hhinc_na = as.numeric(is.na(france$hhinc))
 france$hhinc[france$hhinc==TRUE] = mean(france$hhinc,na.rm=TRUE)
 
 # Recode variable for party vote. Left, Right, Front National and other 
# Use data from CHES 2014, lrgen and lrecon, to classify parties
 france$pr_socialist = ifelse(france$FR_PRTY==4,1,0)
 france$pr_left = ifelse(france$FR_PRTY %in% c(1,2,3,4,5,10),1,0)
 france$pr_frontnational = ifelse(france$FR_PRTY==9,1,0)
 
 # Recode outcome variables (St devs.)
france = france %>% mutate(v27r=scale(4-v27), #higher in original scale meant less support for gov redistribution, recode so higher means more support. 
                           v51r=scale(5-v51), #higher in original scale meant taxes for rich too low, recode so higher means taxes for rich too high 
                           v53r=scale(5-v53), #higher in original scale meant taxes for poor too low, recode so higher means taxes for poor too high 
                           v54r=scale(4-v54), #higher in original scale meant less agreement that French fiscal authorities make sure people pay taxes, recode so higher means more belief in fiscal authorities making sure taxes paid 
                           v55r=scale(4-v55), #higher in original scale meant less agreement that French fiscal authorities treat tax contributors equally under the law without considering their place in society, recode so higher means more belief in fiscal authorities making sure taxes paid evenly/equally across income groups 
                           v57r=scale(4-v57),  #higher in original scale meant less belief that large private firms in France try to avoid paying taxes, recode so higher means more belief they try to avoid taxes
                           v58r=scale(v58-1), #higher means more politicians in France perceived to be implicated in corruption
                           v59r=scale(v59-1)) #higher means more public officials in France perceived to be implicated in corruption



 #additional variables:
 
 
france = france %>% mutate(v46r=scale(5-v46), #higher is less interested in pol (1 to 5), so reversed is to higher MORE interested
                           v47r=scale(v47-1),  #higher is more feel like have say in gov (1 to 5)
                           v48r=scale(5-v48),  #higher is less good understanding of pol (1 to 5), so reversed is to higher MORE understanding of pol
                           firstproblem_econelite = if_else(v35==3, 1, 0 ), #1 if this mentioned as first choice, 0 if not
                           secondproblem_econelite = if_else(v36==3, 1, 0 ),#1 if this mentioned as second choice, 0 if not
                           firstproblem_citizens = if_else(v35==8, 1, 0 ),#1 if this mentioned as third choice, 0 if not
                           secondproblem_citizens = if_else(v36==8, 1, 0 ),#1 if this mentioned as third choice, 0 if not
                           combinedproblem_econelite = if_else(firstproblem_econelite==1 | 
                                                                 secondproblem_econelite==1 , 1, 0 ), 
                           combinedproblem_citizens = if_else(firstproblem_citizens==1 | 
                                                                secondproblem_citizens==1 , 1, 0 ))

france$pol_sophistication <- rowMeans(cbind(france$v48r,
                                            france$v46r), na.rm = T)

france$pol_sophistication_binary <- if_else(france$pol_sophistication >= median(france$pol_sophistication, na.rm=TRUE), 1, 0)

france$v46_bin <- if_else(france$v46r > median(france$v46r, na.rm=TRUE), 1, 0)
france$v48r_bin <- if_else(france$v48r >= median(france$v48r, na.rm=TRUE), 1, 0)


# Export data for entropy balance analysis in Stata
write_dta(france,here("france_ebal.dta"))

  france = france %>% mutate(treat_full=factor(treat_full),
                             treat_1month=factor(treat_1month))
  
```

```{r spain-dataprep, cache=TRUE}
 # Load primary data
 spain <- read_sav(here("DATA_3134.sav"))
 
# Create treatment indicator
 spain = spain %>% mutate(treat_full=case_when(E101 < 3 ~ 0, E101==3~ NA_real_, TRUE ~ 1),
                          treat_2day=case_when(E101 < 3 ~ 0, E101 %in% c(4,5) ~ 1),
                          treat_1day=case_when(E101 == 2 ~ 0, E101 == 4 ~ 1))
                          
# Recode covariates
 spain = spain %>% mutate(female=case_when(P23==2~1, TRUE ~ 0),
                            age=P24,
                            college = case_when(P25A %in%  c(1, 2, 3, 4, 5, 6, 7, 8) ~ 0, 
                                                P25A %in%  c(9, 10, 11, 12, 13, 14) ~ 1),
                            churchattend_never=case_when(P26A %in%  c( 2, 3, 4, 5) ~ 0, 
                                                P26A %in%  c(1) ~ 1), 
                            unemployed = case_when(P31 %in% c(4,5) ~ 1,
                                                   TRUE ~ 0),
                            retired = case_when(P31 == 3 ~ 1,
                                                TRUE ~ 0),
                            region_andalucia = case_when(CCAA == 1 ~ 1, TRUE ~ 0),
                            region_canary = case_when(CCAA == 5 ~ 1, TRUE ~ 0),
                            region_castilla_lamancha = case_when(CCAA == 7 ~ 1, TRUE ~ 0),
                            region_castile_leon = case_when(CCAA == 8 ~ 1, TRUE ~ 0),
                            region_catalonia = case_when(CCAA == 9 ~ 1, TRUE ~ 0),
                            region_valencia = case_when(CCAA == 10 ~ 1, TRUE ~ 0),
                            region_galicia = case_when(CCAA == 12 ~ 1, TRUE ~ 0),
                            region_madrid = case_when(CCAA == 13 ~ 1, TRUE ~ 0),
                            region_basque = case_when(CCAA == 16 ~ 1, TRUE ~ 0),
                            smalltown=case_when(TAMUNI <4  ~ 1, TRUE ~ 0),
                            voted15 = case_when(P21 == 1 ~ 1, TRUE ~ 0),
                            voted15_pp = case_when(P21A == 1 ~ 1, TRUE ~ 0),
                            voted15_dk = case_when(P21A == 99 ~ 1, TRUE ~ 0),
                            hhinc_more = case_when(P37 %in% c(7,8,9,19,11) ~ 1, TRUE ~ 0),
                            hhinc_na = case_when(P37 %in% c(98,99) ~ 1, TRUE ~ 0),)

 # Recode outcome variables
 spain <- spain %>% 
          mutate(polsit = scale(ifelse(P4 > 5, NA, P4 )),
            likelyvote_pp = scale(ifelse(P1201 > 10, NA, P1201 )), #0 to 10, higher is more likely to vote for this party
            likelyvote_psoe = scale(ifelse(P1202 > 10, NA, P1202 )), #0 to 10, higher is mor elikely to vote for this party
            likelyvote_podemos = scale(ifelse(P1203 > 10, NA, P1203 )), #0 to 10, higher is mor elikely to vote for this party
            likelyvote_ciudadanos = scale(ifelse(P1204 > 10, NA, P1204 )),#0 to 10, higher is mor elikely to vote for this party
            firstproblem_corruption = ifelse(P701==11 | P701==37, 1, 0 ), #1 if this mentioned as first choice, 0 if not
            secondproblem_corruption = ifelse(P702==11 | P701==37, 1, 0 ),#1 if this mentioned as second choice, 0 if not
            thirdproblem_corruption = ifelse(P703==11 | P703==37, 1, 0 ),#1 if this mentioned as third choice, 0 if not
            combinedproblem_corruption = ifelse(firstproblem_corruption==1 | 
                                                secondproblem_corruption==1 | 
                                                thirdproblem_corruption==1, 1, 0 ), #1 if this mentioned as first choice, 0 if not
                           vote_PP = ifelse(VOTOSIMG==1, 1, 0),
                           vote_PSOE = ifelse(VOTOSIMG==2, 1, 0),
                           vote_Podemos = ifelse(VOTOSIMG==3, 1, 0),
                           vote_Ciudadanos = ifelse(VOTOSIMG==4, 1, 0))

 #additional variable:
 
 spain = spain %>% mutate(p14r=if_else(P14==9, NA_real_, scale(5-P14)))
 spain$p14r_binary <- if_else(spain$p14r > median(spain$p14r, na.rm=TRUE), 1, 0)

# Export data for entropy balance analysis in Stata
 write_dta(spain,here("spain_ebal.dta"))

 spain = spain %>% mutate(treat_full=factor(treat_full),
                          treat_2day=factor(treat_2day),
                          treat_1day=factor(treat_1day))
```

```{r}

# Run Entropy balancing in Stata, save and fetch results below

eb=read_dta(here("ebal_results_new_binaryedu.dta"))
 eb$mod="ebal"
biv=read_dta(here("biv_results.dta"))
 biv$mod="biv"
dat=rbind(eb,biv)

eb_int=read_dta(here("ebal_results_extrainteractions.dta"))
eb_int$mod="ebal"
biv_int=read_dta(here("biv_results_extrainteractions.dta"))
 biv_int$mod="biv"
dat_int=rbind(eb_int,biv_int)

# Fetch balance tables
btfr=read_dta(here("ebal_fr_treat_1month.dta"))
btes=read_dta(here("ebal_es_treat_2day.dta"))


```


\pagebreak

# Descriptive Statistics


```{r france-desc, cache=TRUE}
france_desc = france %>% select(treat_full,treat_1month,
                                pr_socialist,age,female,tertiary,
                                retired,pol_sophistication_binary, v55r, v57r, v51r, v53r , v27r ,
                                v58r,v59r, combinedproblem_econelite, combinedproblem_citizens) %>% 
                         mutate(treat_full=as.numeric(as.character(treat_full)),
                                treat_1month=as.numeric(as.character(treat_1month)))

summarytools::st_options(descr.stats = c("mean","sd","min","max","n.valid","pct.valid"))

france_desc = as.data.frame(descr(france_desc,transpose = TRUE,
                                  weights=france$WEIGHT,rescale.weights = TRUE))

france_desc$var = rownames(france_desc)
france_desc$var = factor(france_desc$var,
                         levels=c("treat_full","treat_1month",
                                  "pr_socialist","age","female","tertiary",
                                  "retired", "pol_sophistication_binary", 
                                  "v55r", "v57r", "v51r", "v53r", "v27r", "v58r","v59r",
                                   "combinedproblem_econelite", "combinedproblem_citizens"), 
                         labels=c("Treatment, full sample","Treatment, 1 month window",
                                  "Parti Socialiste voter indicator","Age",
                                  "Female indicator","University indicator","Retiree indicator",
                                  "Political sophistication indicator (10)",
                                  "Tax contributors treated equally (1)", "Companies, try to avoid paying taxes (2)",
                                  "Taxes for high income (3)", "Taxes for low income (4)", 
                                  "Gov, reduce income differences (5)", "Politicians corrupt (6)",
                                  "Public officials corrupt (7)", "Economic elite influence gov. policy (8)", "Common people influence gov. policy (9)"))

france_desc = france_desc %>% select(var, everything())
colnames(france_desc)[1] = "Variable"
kable(france_desc,"latex", booktabs = T,digits=c(0,2,2,2,0,2,0,2,2,2,2,2,2,2,2, 2, 2),row.names = FALSE,
      caption="Descriptive Statistics for Data on France") %>% 
      kable_styling(latex_options = "hold_position",position="center") %>% 
      pack_rows("Treatment indicators", 1, 2) %>%
      pack_rows("Independent variables", 3, 8) %>% 
      pack_rows("Dependent variables", 9, 17)
```


The full wording of the questions used as dependent variables:

**For perceptions of tax compliance in France**

1. "In general, how often do you think that the tax authorities in France do the following...treat all tax contributors equally under the law, without considering their place in society." Respondents could give one of four answers, ranging from "Almost always" to "almost never".

2. "In general, how often do you think that major private companies in [COUNTRY] do the following... try to avoid paying their taxes?." Respondents could give one of four answers, ranging from "Almost always" to "almost never". 

**For redistributive attitudes in France**

3. "Generally, how would you describe taxes in France today? ...First, for those with high incomes, are taxes:" Respondents could give one of five answers, ranging from "much too high" to "much too low".

4.  "Generally, how would you describe taxes in France today? ...Lastly, for those with low incomes, are taxes:" Respondents could give one of five answers, ranging from "much too high" to "much too low".

5. "On the whole, do you think it should or should not be the government's responsibility... to reduce income differences between the rich and the poor." Respondents could give one of four answers, ranging from "definitely should be" to "definitely should not be".

**For corruption beliefs in France**

6. "In your opinion, about how many politicians in France are involved in corruption?" Respondents could give one of five answers, ranging from "Almost none" to "almost all". 

7. "In your opinion, about how many public officials in France are involved in corruption?" Respondents could give one of five answers, ranging from "Almost none" to "almost all".
 
8. [Alternative corruption question] "Here is a list of people or organization that might influence the government policy-making. Write down the people or organizations that influence government policy-making in France the most, in first place and second place." Respondents who choose the "economic sector, banks and industry" as either first or second are coded as 1, otherwise coded as 0.

9.  [Alternative corruption question] "Here is a list of people or organization that might influence the government policy-making. Write down the people or organizations that influence government policy-making in France the most, in first place and second place." Respondents who choose the "citizens in general" as either first or second are coded as 1, otherwise coded as 0.

**For political sophistication indicator in France**

10. We combine the answers to the following two questions:

  - A. "How interested are you in politics?" Respondents could give one of five answers, from "not at all" to "a lot". 

  - B. "I understand pretty well the big questions in the national political debate". Respondents could give one of five answers, from "disagree strongly" to "agree strongly". 

  - These two items were recaled, such that the mean was at 0, with 1 unit representing a one standard deviation from 0. The average between these two items was then calculated, with a Cronbach's alpha of 0.53 obtained. A median split of this variable was then performed, in order to create "high" (at or above the median) and "low" (below the median) levels of political sophistication.


\pagebreak

```{r spain-desc, cache=TRUE}
spain_desc = spain %>% select(treat_full,treat_2day,treat_1day,
                              voted15_pp,churchattend_never,unemployed,smalltown,
                              region_andalucia, region_canary, region_castilla_lamancha, 
                              region_castile_leon, region_catalonia, region_valencia, region_galicia,	
                              region_madrid, region_basque,p14r_binary, likelyvote_ciudadanos,likelyvote_podemos,
                              likelyvote_psoe, likelyvote_pp,firstproblem_corruption,
                              combinedproblem_corruption, vote_PP,vote_PSOE,vote_Podemos,
                              vote_Ciudadanos) %>% 
                              mutate(treat_full=as.numeric(as.character(treat_full)),                                                        
                                     treat_2day=as.numeric(as.character(treat_2day)), 
                                     treat_1day=as.numeric(as.character(treat_1day)))

spain_desc = as.data.frame(summarytools::descr(spain_desc,transpose = TRUE,na.rm=T))
spain_desc$var = rownames(spain_desc)

spain_desc$var = factor(spain_desc$var,
                        levels=c("treat_full","treat_2day","treat_1day",
                                 "voted15_pp","churchattend_never","unemployed","smalltown",
                                 "region_andalucia", "region_canary", "region_castilla_lamancha", 
                                 "region_castile_leon", "region_catalonia", "region_valencia", 
                                 "region_galicia",	"region_madrid", "region_basque", "p14r_binary",
                                 "likelyvote_ciudadanos",
                                 "likelyvote_podemos", "likelyvote_psoe","likelyvote_pp",
                                 "firstproblem_corruption", "combinedproblem_corruption", "vote_PP",
                                 "vote_PSOE","vote_Podemos","vote_Ciudadanos"),
                        labels=c("Treatment, full sample","Treatment, 2 day window","Treatment, 1 day window",
                                 "Voted PP in 2015","Never attends church indicator", 
                                 "Unemployed indicator", "Small town indicator", "Andalucia","Canary Islands",
                                 "Castilla - La Mancha","Castile and Leon","Catalonia","Valencia","Galicia","Madrid",
                                 "Basque Country", "Political sophistication"  ,"Ciudadanos, likely vote (1)","Podemos, likely vote (1)","PSOE, likely vote (1)",
                                 "PP, likely vote (1)","Corruption MIP, First mention indicator",
                                 "Corruption MIP, combined indicator","Would vote PP indicator (2)",
                                 "Would vote POSE indicator (2)","Would vote Podemos indicator (2)","Would vote Ciudadanos (2)"))

spain_desc = spain_desc %>% select(var, everything()) %>% arrange(var)
colnames(spain_desc)[1] = "Variable"

kable(spain_desc,"latex", booktabs = T,digits=c(2),row.names = FALSE,
      caption="Descriptive Statistics for Data on Spain") %>% 
      kable_styling(latex_options = "hold_position",position="center") %>% 
      pack_rows("Treatment indicators", 1, 3) %>%
      pack_rows("Independent variables", 4, 17) %>% 
      pack_rows("Dependent variables", 18, 27)

```

**The full wording of the questions used as dependent variables in Spain**

1. "As you know, in Spain there are different political parties and coalitions for which you can vote during an election. Please report the probability that you would vote for each of the following parties, using a scale from 0 to 10, where 0 represents 'with complete certainty, I would never vote for them,' and 10 represents 'with complete certainty, I would always vote for them'." Respondents were shown 5 political parties, plus an additional 1-3 regional parties if they lived in the particular regions. 

2. [Alternative voting question] "Supposing that a general election were held tomorrow -- meaning a vote for the Spanish Parliament -- for which party would you vote?" Respondents were not given response options, but their answers were coded according to the main party options, regional options, as well as various non-participatory options.   

The four major parties in Spain at the time were: the conservative Partido Popular (PP), the social democratic Partido Socialista Obrero Español (PSOE), the left-wing populist Podemos, and the centrist Ciudadanos. In the subsequent June 2016 elections the four parties collectively received about 90\% of all votes (33.0\%, 22.6\%, 21.2\%, and 13.1\%, respectively).    

**The political sophistication indicator in Spain**

3. "As you know, after the election this past December 20, the political parties have begin to negotiate forming a government. I would like for you to tell me with how much interest have you followed the news about these negotiations." Respondents were given a 5 pt scale, from "with much interest" to "with no interest". 


## Google Trends Analysis

Analysis reported in paper.

```{r}

# Load primary data
gtrends=read_csv(here("googletrends_2020_06_02.csv")) %>% 
   pivot_longer(cols=c(panama_papers,euro_2016,trump)) %>% 
   mutate(name=factor(name,levels=c("panama_papers","euro_2016","trump"),
                      labels=c("Panama Papers","Euro 2016","Trump"))) %>% 
   ggplot() + 
   aes(x = day, y = value, group=name, color=name,shape=name,linetype=name) + 
   facet_wrap(~country,ncol=1)+
   
   geom_vline(xintercept=ymd("2016-04-03"), colour="gray40") +
   geom_line()+
   scale_y_continuous("Relative search interest") +
   scale_x_date("",breaks = c(ymd("2016-03-03"),
                                  ymd("2016-04-03"),
                                  ymd("2016-05-03")),date_labels = "%b %d") +
   scale_color_brewer(palette="Set1")+
   theme(legend.title = element_blank(), legend.key = element_blank(),
         legend.position = 'bottom', legend.direction = 'horizontal',
         legend.box.spacing = unit(0.1,"cm"),
         legend.text = element_text(size=12),
         axis.title.y=element_text(hjust=0.5))

gtrends + labs(title="Google Trends Keyword Searches around April 3, 2016")
ggsave(here("fig0_gtrends.png"),gtrends, width=8, height=5)

```

## Balance Tests 

Below are the results of balance tests for the different treatment windows (Markers refer to different treatment windows). We regress the treatment indicator on each covariate seperately. The figures show the p-values of each covariate --- low values signify that the covariate is correlated with treatment status. In the French data, age, education, and an indicator for retirement are significantly imbalanced, while in the Spanish data, church attendance, town size, and multiple regional indicator variables are imbalanced. To account for such correlations, our main analysis is based on entropy balance matching which balances the values of covariates with a p-value below 0.05. 

```{r france-balance, cache=TRUE}
balance_test <- 
   data.frame(
      treat_var = c(rep("treat_full", 12),
                       rep("treat_1month", 12)),
      treat_window = c(rep("Full", 12),
                 rep("1 month", 12)),
     variable = c(rep(c("female", "age", "educyrs","unemployed", "retired","union", "top40",  "churchattend_never","pol_sophistication_binary","pr_socialist","pr_left","pr_frontnational"), 2)),
     var_name = c(rep(c("Female", "Age", "University","Unemployed", "Retired","Union member", 
                        "Household income in top 40%", "Never attends church","Political sophistication","Voted for Socialists",
                        "Voted for a left party","Voted for Front National"), 2)),
     pval = NA)
 
 balance_test = balance_test %>% 
    mutate(treat_window=fct_relevel(factor(treat_window), "1 month",
                                                          "Full"),
            var_name=fct_relevel(factor(var_name), "Voted for Front National",
                                                    "Voted for Socialists",
                                                     "Voted for a left party",
                                                    "Political sophistication",
                                                     "Union member",
                                                    "Unemployed",
                                                    "Retired",
                                                    "Household income in top 40%",
                                                    "Never attends church",
                                                    "University",
                                                    "Female",
                                                    "Age"))

 for (j in unique(balance_test$treat_var)) {
    for (i in unique(balance_test$variable)) {
       balance_test$pval[balance_test$treat_var == j & balance_test$variable == i] <- 
          coef(summary(lm(eval(as.symbol(i)) ~ eval(as.symbol(j)), 
                          data = france)))[paste0("eval(as.symbol(j))","1"),"Pr(>|t|)"]
    }
 }
 
 
 ggplot(balance_test, aes(x=var_name, y=pval, group=treat_window, color=treat_window, shape=treat_window)) +
   geom_point(size=4, alpha=0.75) + 
   scale_x_discrete("") +
   scale_y_continuous("P-value", lim=c(0,1)) +
   scale_color_brewer(palette="Set1")+
   geom_hline(yintercept = 0.05, linetype="dashed", color="gray40") +
   coord_flip()+
   theme(legend.position="top")+
      ggtitle("Balance Tests for Treatment Indicators in French Data") +
    theme(plot.title = element_text(hjust = 0.5, face = 'bold',size = 12))
 
 ggsave(here("figA1_france_balance.png"), width=7, height=4)
 
```

```{r spain-balance, cache=TRUE,fig.height=6}
 balance_test <- 
   data.frame(
      treat_var = c(rep("treat_full", 20),
                    rep("treat_2day", 20),
                    rep("treat_1day", 20)),
      treat_window = c(rep("Full", 20),
                 rep("2 day", 20),
                 rep("1 day", 20)),
     var = c(rep(c("female", "age", "college", "unemployed", "retired", "hhinc_more", 
                   "churchattend_never", "smalltown","p14r","voted15","voted15_pp",
                   "region_andalucia","region_canary","region_castilla_lamancha","region_castile_leon",
                   "region_catalonia","region_valencia","region_galicia","region_madrid","region_basque"), 3)),
     var_name = c(rep(c("Female", "Age", "College", "Unemployed", "Retired", "High household income", 
                        "Never attends church", "Small town","Political sophistication","Voted in 2015","Voted PP in 2015",
                        "Andalucia","Canary Islands","Castilla - La Mancha",
                        "Castile and Leon","Catalonia","Valencia","Galicia","Madrid","Basque Country"), 3)),
     pval = NA)

 balance_test = balance_test %>% 
    mutate(treat_window=fct_relevel(factor(treat_window), "1 day", 
                                                          "2 day",
                                                          "Full"),
             var_name=fct_relevel(factor(var_name), "Valencia",
                                  "Madrid",
                                  "Galicia",
                                  "Catalonia",
                                  "Castilla - La Mancha",
                                  "Castile and Leon",
                                  "Canary Islands",
                                  "Basque Country",
                                  "Andalucia",
                                  "Small town",
                                  "Unemployed",
                                  "Party voted 2015 NA",
                                  "Voted PP in 2015",
                                  "Voted in 2015"))

 
 for (j in unique(balance_test$treat_var)) {
   for (i in unique(balance_test$var)) {
      balance_test$pval[balance_test$treat_var == j & balance_test$var == i] <- 
         coef(summary(lm(eval(as.symbol(i)) ~ eval(as.symbol(j)), 
                         data = spain)))[paste0("eval(as.symbol(j))","1"),"Pr(>|t|)"]
   }
 }
 
 ggplot(balance_test, aes(x=var_name, y=pval, group=treat_window, 
                          color=treat_window, shape=treat_window)) +
   geom_point(size=4, alpha=0.75) + 
   scale_x_discrete("") +
   scale_y_continuous("P-value", lim=c(0,1)) +
   scale_color_brewer(palette="Set1")+
   geom_hline(yintercept = 0.05, linetype="dashed", color="gray40") +
   coord_flip()+
   theme(legend.position="top")+
          ggtitle("Balance Tests for Treatment Indicators in Spanish Data") +
    theme(plot.title = element_text(hjust = 0.5, face = 'bold',size = 12))

 
 ggsave(here("figA2_spain_balance.png"), width=7, height=6)
 
```


## Balance Tables

```{r}

btfr %>% select(Xname,mean_Tr, mean_Co_Pre, mean_Co_Post, var_Tr, var_Co_Pre, var_Co_Post)  %>% 
   mutate(Xname=case_when(Xname=="female"~"Female",
                          Xname=="age" ~ "Age",
                          Xname=="tertiary" ~ "University educated",
                          Xname=="retired" ~ "Retired")) %>% 
  kable("latex", 
        booktabs = T,
        digits=c(0,2,2,2,2,2,2),
        row.names = FALSE,
        col.names=c("Covariate","","Pre","Post","","Pre","Post"),
        caption="French Data: Covariate Balance Before and After Entropy Reweighting") %>%
        kable_styling(latex_options = "hold_position",position="center", full_width = F) %>%
        add_header_above(c(" ", "Treatment" = 1, "Control" = 2,"Treatment" = 1, "Control" = 2)) %>%
        add_header_above(c(" " = 1, "Mean" = 3, "Variance" = 3)) 

```

Reweighting based on matching first and second moments of covariates to treatment values using the ebalance package in Stata. Sample weights provided with the data used as base weights before matching.
                 
```{r}

btes %>% select(Xname,mean_Tr, mean_Co_Pre, mean_Co_Post, var_Tr, var_Co_Pre, var_Co_Post)  %>% 
      mutate(Xname=case_when(Xname=="college"~"College indicator",
                          Xname=="churchattend_never" ~ "Never attends church indicator",
                          Xname=="unemployed" ~ "Unemployed",
                          Xname=="smalltown" ~ "Small town",
                          Xname=="region_andalucia" ~ "Andalucia",
                          Xname=="region_canary" ~ "Canary Islands",
                          Xname=="region_castilla_lamancha" ~ "Castilla - La Mancha",
                          Xname=="region_castile_leon"~ "Castile and Leon",
                          Xname=="region_catalonia"~ "Catalonia",
                          Xname=="region_valencia" ~ "Valencia",
                          Xname=="region_galicia" ~ "Galicia",
                          Xname=="region_madrid" ~ "Madrid",
                          Xname=="region_basque" ~ "Basque Country")) %>% 
  kable("latex", 
        booktabs = T,
        digits=c(0,2,2,2,2,2,2),
        row.names = FALSE,
        col.names=c("Covariate","","Pre","Post","","Pre","Post"),
        caption="Spanish Data: Covariate Balance Before and After Entropy Reweighting") %>%
        kable_styling(latex_options = "hold_position",position="center",full_width = F) %>%
        add_header_above(c(" ", "Treatment" = 1, "Control" = 2,"Treatment" = 1, "Control" = 2)) %>%
        add_header_above(c(" " = 1, "Mean" = 3, "Variance" = 3))

```

\pagebreak


# Main Analysis and Alternative Specifications 

In this section we reproduce figures from the main analysis along with several robustness checks. First, we change the model specification and use a simple bivariate regression of the outcome variables on the main treatment indicators. Second, we show results when we change the treatment window bandwidth: In the French case we compare the one month window to the full sample window, whereas in the Spanish case we compare the 2 day window to a 1 day window as well as the full sample window. Finally, in the Spanish case we report the results of an alternative dependent variable: Vote choice as captured by a "Sunday question". As the additional variable is an indicator variable, we report the results in terms of changes in predicted probability for the relevant variable. Due to the high correlation between prior vote choice and current vote intentions the subsample size for the voting variables becomes extremely small. As a consequence, we do not report results by subsample for the voting variables.

```{r}

# Functions to create standardized plots
left_plot <- function (p) {
   ggplot(p) + 
   aes(x = dv_name, y = est, color=type_name,shape=type_name,linetype=type_name) + 
   geom_hline(yintercept=0, colour="gray40") +
   geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,alpha=0.7,
                 width=0,position=position_dodge(width = 0.5)) +
   geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), 
                 width=0,position=position_dodge(width = 0.5)) + 
   geom_point(size = 3,position=position_dodge(width = 0.5)) +
   scale_y_continuous("") +
   scale_x_discrete("") +
   scale_color_brewer(palette="Set1")+
   facet_wrap(~panel)+
   expand_limits(y=c(-1,1))+
   theme(legend.title = element_blank(), legend.key = element_blank(),
         legend.position = 'bottom', legend.direction = 'horizontal',
         plot.margin = margin(2, 0, 10, 10)) +
   coord_flip()
}

right_plot <- function (p) {
   ggplot(p)+
   aes(x = dv_name, y = est) + 
   geom_hline(yintercept=0, colour="gray40") +
   geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,
                 width=0,position=position_dodge(width = 0.3)) +
   geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), width=0,
                 position=position_dodge(width = 0.3)) + 
   geom_point(size = 3,position=position_dodge(width = 0.3)) +
   facet_wrap(~panel)+
   expand_limits(y=c(-1,1))+
   scale_y_continuous("") +
   scale_x_discrete("") +
   theme(legend.title = element_blank(), legend.key = element_blank(),
         legend.position = 'bottom', legend.direction = 'horizontal',
         axis.text.y = element_blank(),
         plot.margin = margin(2, 10, 10, 0)) +
   coord_flip()
   }

final_plot <- function (left,right) {   
    leg = get_legend(left + 
            guides(color = guide_legend(nrow = 1)) +
            theme(legend.position = "top",
                  plot.margin = margin(10,0,0,0)))

    com=plot_grid(left + theme(legend.position="none"),
          right, ncol=2,
          align="h",rel_widths = c(0.6,0.4))

    plot_grid(com,leg,ncol = 1, rel_heights = c(1,.1))
}

title_plot <- function(final_plot,titl="",subtitl="") {
   title= ggdraw() + 
   draw_label(titl,
    fontface = 'bold',
    size = 12,
    x = 0,
    hjust = 0
  ) +
  theme(
    # add margin on the left of the drawing canvas,
    # so title is aligned with left edge of first plot
    plot.margin = margin(0, 0, 5, 10)
  )
   subtitle= ggdraw() + 
   draw_label(subtitl,
   size = 10,
    x = 0,
    hjust = 0
  ) +
  theme(
    # add margin on the left of the drawing canvas,
    # so title is aligned with left edge of first plot
    plot.margin = margin(0, 0, 10, 10)
  )
plot_grid(
  title, subtitle,final_plot,
  ncol = 1,
  # rel_heights values control vertical title margins
  rel_heights = c(0.1,0.07, 1)
)
}


left_plot_solo <- function (p) {
  ggplot(p) + 
    aes(x = dv_name, y = est, color=type_name,shape=type_name) + 
    geom_hline(yintercept=0, colour="gray40") +
    geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,
                  width=0,position=position_dodge(width = 0.5)) +
    geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), 
                  width=0,position=position_dodge(width = 0.5)) + 
    geom_point(size = 3,position=position_dodge(width = 0.5)) +
    scale_y_continuous("") +
    scale_x_discrete("") +
    scale_color_brewer(palette="Set1")+
    expand_limits(y=c(-2,2))+
    theme(legend.title = element_blank(), legend.key = element_blank(),
          legend.position = 'bottom', legend.direction = 'horizontal',
          plot.margin = margin(2, 0, 10, 10))  +  
    theme(plot.margin = margin(0, 0, 5, 10)) +
    coord_flip() +  guides(col=guide_legend(nrow=2,byrow=TRUE)) 
    }

```

\pagebreak 


## Redistributive Attitudes in France

```{r redpref, cache=TRUE}
# Prepare for plotting
redpref = dat %>% filter(dv %in% c("v27r","v51r","v53r") &
                        type %in% c("Main",
                                    "top40, 0", 
                                    "top40, 1", 
                                    "top40, dx")) %>% 
               mutate(panel=case_when(type=="Main" ~ "Average effects", #  "All respondents",
                                      type=="top40, dx" ~ "Marginal differences by income",
                                      TRUE ~ "Average effects"), # "Income subgroups"))
                     dv_name = case_when(
                         dv == "v53r" ~ "Taxes for low\nincome too high",
                         dv == "v51r" ~ "Taxes for high\nincome too high",
                         dv == "v27r" ~ "Gov should reduce \n income differences"),
                     type_name=case_when(
                         type == "Main" ~ "All respondents",
                         type == "top40, 1" ~ "Subsample: Top 40% income",
                         type == "top40, 0" ~ "Subsample: Bottom 60% income",
                         type =="top40, dx" ~ "Marginal differences by income"))
```

### Analysis Reported in Main Paper

```{r redpref-figs, cache=TRUE}
# Figure in paper
left = redpref %>% filter(type %in% c("Main","top40, 0", "top40, 1") &
                           treat=="treat_1month" &
                            mod=="ebal") %>% left_plot() 
right = redpref %>% filter(type %in% c("top40, dx"),
                           treat=="treat_1month" &
                            mod=="ebal") %>% right_plot()

final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig2_red_main.png"),final, width=9, height=6)
```

#### Regression Results


```{r, echo=FALSE, fig.align='center'}
knitr::include_graphics("fr_red_main.PNG")
```


### Alternative Specifications

#### Bivariate Regression of Outcome on Treatment Indicator (No Matching)
```{r redpref-figs-biv, cache=TRUE}
# Alternative spec: Simple regression, no balancing
left = redpref %>% filter(type %in% c("Main","top40, 0", "top40, 1") &
                           treat=="treat_1month" &
                            mod=="biv") %>% left_plot() + expand_limits(y=1)
right = redpref %>% filter(type %in% c("top40, dx"),
                           treat=="treat_1month" &
                            mod=="biv") %>% right_plot()

final=final_plot(left,right)   

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, bivariate specification")

ggsave(here("fig2A_red_biv.png"), final, width=9, height=6)
```

#### Full Sample Bandwith (Not One Month)

```{r redpref-figs-full, cache=TRUE}
# Alternative spec: Full sample bandwidth
left = redpref %>% filter(type %in% c("Main","top40, 0", "top40, 1") &
                           treat=="treat_full" &
                            mod=="ebal") %>% left_plot() + expand_limits(y=1)
right = redpref %>% filter(type %in% c("top40, dx"),
                           treat=="treat_full" &
                            mod=="ebal") %>% right_plot()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "Full sample treatment window, entropy balance matching specification")

ggsave(here("fig2A_red_full.png"), final,width=9, height=6)
```


#### Regression of Outcome on Treatment Indicator and Political Sophistication Moderator 

```{r redist_moderation, cache=TRUE}

redpref2 = dat_int %>% filter(dv %in% c("v27r","v51r","v53r") &
                             type %in% c("polsop_top40, 0 both",
                                         "polsop_top40, 0 polsop, 1 other",
                                         "polsop_top40, 1 polsop, 0 other",
                                         "polsop_top40, 1 both"))  %>% 
  mutate(      
    dv_name = case_when(
    dv == "v53r" ~ "Taxes for low \n income too high",
    dv == "v51r" ~ "Taxes for high \n income too high",
    dv == "v27r" ~ "Gov should reduce \n income differences"),
    type_name=case_when(
      type == "polsop_top40, 0 both" ~ "Bottom 60% income, low sophisticates",
      type == "polsop_top40, 0 polsop, 1 other" ~ "Top 40% income, low sophisticates",
      type == "polsop_top40, 1 polsop, 0 other" ~ "Bottom 60% income, high sophisticates",
      type == "polsop_top40, 1 both" ~ "Top 40% income, high sophisticates"))

left = redpref2 %>% filter(treat=="treat_1month" & 
                              mod=="ebal" &
                              type %in% c("polsop_top40, 0 both",
                                         "polsop_top40, 0 polsop, 1 other",
                                         "polsop_top40, 1 polsop, 0 other",
                                         "polsop_top40, 1 both")) %>% left_plot_solo()


title_plot(left,"Average effects of treatment by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig2A_redist_moderated.png"),left, width=8, height=4)

```


\pagebreak 

## Corruption in France

```{r corr, cache=TRUE}
corr_fr = dat %>% filter(dv %in% c("v58r","v59r") &
                            type %in% c("Main",
                                        "pr_socialist, 0", 
                                        "pr_socialist, 1", 
                                        "pr_socialist, dx"))

corr_fr = corr_fr %>% mutate(      
  dv_name = case_when(
    dv == "v58r" ~ "Politicians corrupt",
    dv == "v59r" ~ "Public officials corrupt"),
  type_name=case_when(
    type == "Main" ~ "All respondents",
    type == "pr_socialist, 1" ~ "Subsample: Socialist Party voters",
    type == "pr_socialist, 0" ~ "Subsample: Other respondents",
    type == "pr_socialist, dx" ~ "Marginal effect by party"), 
  type_name=fct_relevel(factor(type_name),c("All respondents", 
                                            "Subsample: Socialist Party voters",
                                            "Subsample: Other respondents")),
  panel=case_when(type=="Main" ~ "Average effects", #  "All respondents",
                  type=="pr_socialist, dx" ~ "Marginal differences by party",
                  TRUE ~ "Average effects") # "Income subgroups"))
)
```

### Analysis Reported in Main Paper

```{r corr-figs1, cache=TRUE}
# Figure in paper
left = corr_fr %>% filter(treat=="treat_1month" & 
                             mod=="ebal" &
                             type %in% c("Main",
                                         "pr_socialist, 0",
                                         "pr_socialist, 1")) %>% 
                                         left_plot()
right = corr_fr %>% filter(treat=="treat_1month" &
                              mod=="ebal" &
                              type %in% c("pr_socialist, dx")) %>% right_plot()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig3_corr_main.png"),final, width=7, height=4)
```

#### Regression Results


```{r, echo=FALSE, fig.align='center'}
knitr::include_graphics("fr_corr_main.PNG")
```



### Alternative Specifications


#### Bivariate Regression of Outcome on Treatment Indicator (No Matching)

```{r corr-figs-biv2}
# Alternative spec: Simple regression, no balancing k
left = corr_fr %>% filter(treat=="treat_1month" & 
                             mod=="biv" &
                             type %in% c("Main",
                                         "pr_socialist, 0",
                                         "pr_socialist, 1")) %>% left_plot()
right = corr_fr %>% filter(treat=="treat_1month" &
                              mod=="biv" &
                              type %in% c("pr_socialist, dx")) %>% right_plot()
final=final_plot(left,right) 
 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, bivariate specification")

ggsave(here("fig3A_corr_biv.png"),final, width=8, height=4)
```

#### Full Sample Bandwith (Not One Month)

```{r corr-figs-full, cache=TRUE}
# Alternative spec: Full sample bandwidth
left = corr_fr %>% filter(treat=="treat_full" & 
                             mod=="ebal" &
                             type %in% c("Main",
                                         "pr_socialist, 0",
                                         "pr_socialist, 1")) %>% left_plot()
right = corr_fr %>% filter(treat=="treat_full" &
                              mod=="ebal" &
                              type %in% c("pr_socialist, dx")) %>% right_plot()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "Full sample treatment window, entropy balance matching specification")

ggsave(here("fig3A_corr_full.png"), final,width=9, height=6)
```


#### Regression of Outcome on Treatment Indicator and Political Sophistication Moderator 

```{r corrupt_moderation, cache=TRUE}

corr_fr2 = dat_int %>% filter(dv %in% c("v58r","v59r") &
                             type %in% c("polsop_pr, 0 both",
                                         "polsop_pr, 0 polsop, 1 other",
                                         "polsop_pr, 1 polsop, 0 other",
                                         "polsop_pr, 1 both"))  %>% 
  mutate(      
    dv_name = case_when(
    dv == "v58r" ~ "Politicians corrupt",
    dv == "v59r" ~ "Public officials corrupt"),
    type_name=case_when(
    type == "polsop_pr, 0 both" ~ "Other respondents, low sophisticates",
    type == "polsop_pr, 0 polsop, 1 other" ~ "Socialist voters, low sophisticates",
    type == "polsop_pr, 1 polsop, 0 other" ~ "Other respondents, high sophisticates",
    type == "polsop_pr, 1 both" ~ "Socialist voters, high sophisticates"),
      type_name=fct_relevel(factor(type_name), 
                        "Socialist voters, high sophisticates", 
                        "Socialist voters, low sophisticates", 
                        "Other respondents, high sophisticates",
                        "Other respondents, low sophisticates"))

left = corr_fr2 %>% filter(treat=="treat_1month" & 
                              mod=="ebal" &
                            type %in% c("polsop_pr, 0 both",
                                         "polsop_pr, 0 polsop, 1 other",
                                         "polsop_pr, 1 polsop, 0 other",
                                         "polsop_pr, 1 both")) %>% left_plot_solo()


title_plot(left,"Average effects of treatment by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig3A_corrupt_moderated.png"),left, width=8, height=4)

```

#### Alternative Outcome Measure - Main Effect

```{r corr_alt, cache=TRUE}

#different scale, so tweak plots:

left_plot2 <- function (p) {
   ggplot(p) + 
   aes(x = dv_name, y = est, color=type_name,shape=type_name,linetype=type_name) + 
   geom_hline(yintercept=0, colour="gray40") +
   geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,alpha=0.7,
                 width=0,position=position_dodge(width = 0.5)) +
   geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), 
                 width=0,position=position_dodge(width = 0.5)) + 
   geom_point(size = 3,position=position_dodge(width = 0.5)) +
   scale_y_continuous("") +
   scale_x_discrete("") +
   scale_color_brewer(palette="Set1")+
   facet_wrap(~panel)+
   expand_limits(y=c(-0.5,0.5))+
   theme(legend.title = element_blank(), legend.key = element_blank(),
         legend.position = 'bottom', legend.direction = 'horizontal',
         plot.margin = margin(2, 0, 10, 10)) +
   coord_flip()
}

right_plot2 <- function (p) {
   ggplot(p)+
   aes(x = dv_name, y = est) + 
   geom_hline(yintercept=0, colour="gray40") +
   geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,
                 width=0,position=position_dodge(width = 0.3)) +
   geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), width=0,
                 position=position_dodge(width = 0.3)) + 
   geom_point(size = 3,position=position_dodge(width = 0.3)) +
   facet_wrap(~panel)+
   expand_limits(y=c(-0.5,0.5))+
   scale_y_continuous("") +
   scale_x_discrete("") +
   theme(legend.title = element_blank(), legend.key = element_blank(),
         legend.position = 'bottom', legend.direction = 'horizontal',
         axis.text.y = element_blank(),
         plot.margin = margin(2, 10, 10, 0)) +
   coord_flip()
   }



corr_fr = dat %>% filter(dv %in% c("ecelite","citizens") &
                            type %in% c("Main",
                                        "pr_socialist, 0", 
                                        "pr_socialist, 1", 
                                        "pr_socialist, dx"))

corr_fr = corr_fr %>% mutate(      
  dv_name = case_when(
    dv == "ecelite" ~ "Economic elite \n influence gov. policy",
    dv == "citizens" ~ "Common people \n influence gov. policy"),
  type_name=case_when(
    type == "Main" ~ "All respondents",
    type == "pr_socialist, 1" ~ "Subsample: Socialist Party voters",
    type == "pr_socialist, 0" ~ "Subsample: Other respondents",
    type == "pr_socialist, dx" ~ "Marginal effect by party"), 
  type_name=fct_relevel(factor(type_name),c("All respondents", 
                                            "Subsample: Socialist Party voters",
                                            "Subsample: Other respondents")),
  panel=case_when(type=="Main" ~ "Average effects", #  "All respondents",
                  type=="pr_socialist, dx" ~ "Marginal differences by party",
                  TRUE ~ "Average effects") # "Income subgroups"))
)

left = corr_fr %>% filter(treat=="treat_1month" & 
                             mod=="ebal" &
                             type %in% c("Main",
                                         "pr_socialist, 0",
                                         "pr_socialist, 1")) %>% 
                                         left_plot2()
right = corr_fr %>% filter(treat=="treat_1month" &
                              mod=="ebal" &
                              type %in% c("pr_socialist, dx")) %>% right_plot2()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig3A_corr_alt.png"),final, width=9, height=6)



```

#### Alternative Outcome Measure - Moderation Effect

```{r corrupt_moderation_alt, cache=TRUE}

#again tweak plot:


left_plot_solo2 <- function (p) {
  ggplot(p) + 
    aes(x = dv_name, y = est, color=type_name,shape=type_name) + 
    geom_hline(yintercept=0, colour="gray40") +
    geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,
                  width=0,position=position_dodge(width = 0.5)) +
    geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), 
                  width=0,position=position_dodge(width = 0.5)) + 
    geom_point(size = 3,position=position_dodge(width = 0.5)) +
    scale_y_continuous("") +
    scale_x_discrete("") +
    scale_color_brewer(palette="Set1")+
    expand_limits(y=c(-0.5,0.5))+
    theme(legend.title = element_blank(), legend.key = element_blank(),
          legend.position = 'bottom', legend.direction = 'horizontal',
          plot.margin = margin(2, 0, 10, 10))  +  
    theme(plot.margin = margin(0, 0, 5, 10)) +
    coord_flip() +  guides(col=guide_legend(nrow=2,byrow=TRUE)) 
    }


corr_fr2 = dat_int %>% filter(dv %in% c("ecelite","citizens") &
                             type %in% c("polsop_pr, 0 both",
                                         "polsop_pr, 0 polsop, 1 other",
                                         "polsop_pr, 1 polsop, 0 other",
                                         "polsop_pr, 1 both"))  %>% 
  mutate(      
    dv_name = case_when(
    dv == "ecelite" ~ "Economic elite \n influence gov. policy",
    dv == "citizens" ~ "Common people \n influence gov. policy"),
    type_name=case_when(
    type == "polsop_pr, 0 both" ~ "Other respondents, low sophisticates",
    type == "polsop_pr, 0 polsop, 1 other" ~ "Socialist voters, low sophisticates",
    type == "polsop_pr, 1 polsop, 0 other" ~ "Other respondents, high sophisticates",
    type == "polsop_pr, 1 both" ~ "Socialist voters, high sophisticates"),
      type_name=fct_relevel(factor(type_name), 
                        "Socialist voters, high sophisticates", 
                        "Socialist voters, low sophisticates", 
                        "Other respondents, high sophisticates",
                        "Other respondents, low sophisticates"))

left = corr_fr2 %>% filter(treat=="treat_1month" & 
                              mod=="ebal" &
                            type %in% c("polsop_pr, 0 both",
                                         "polsop_pr, 0 polsop, 1 other",
                                         "polsop_pr, 1 polsop, 0 other",
                                         "polsop_pr, 1 both")) %>% left_plot_solo2()


title_plot(left,"Average effects of treatment by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig3A_corrupt_mod_alt.png"),left, width=8, height=4)

```

\pagebreak 

## Voting Intentions in Spain
```{r spainvote, cache=TRUE}
vote_sp = dat %>% filter(dv %in% c("likelyvote_ciudadanos",
                                  "likelyvote_podemos",
                                  "likelyvote_psoe",
                                  "likelyvote_pp") )

 vote_sp = vote_sp %>% mutate(      
             dv_name = case_when(
                dv == "likelyvote_ciudadanos" ~ "Ciudadanos,\n likely vote",
                dv == "likelyvote_podemos" ~ "Podemos,\n likely vote",
                dv == "likelyvote_pp" ~ "PP, likely vote",
                dv == "likelyvote_psoe" ~ "PSOE, likely vote"),
          type_name=case_when(
                type == "Main" ~ "All respondents",
                type == "Voted PP, 1" ~ "Subsample:\nPP voters",
                type == "Voted PP, 0" ~ "Subsample:\nOther respondents",
                type == "Voted PP, dx" ~ "Marginal effect by party"),
            type_name=fct_relevel(factor(type_name), 
                                       "All respondents",
                                       "Subsample:\nPP voters",
                                       "Subsample:\nOther respondents"),
             panel=case_when(type=="Main" ~ "Average effects", 
                             type=="Voted PP, dx" ~ "Marginal differences by party",
                             TRUE ~ "Average effects"))
```


### Analysis Reported in Main Paper

```{r spainvote-figs, cache=TRUE}
# Figure in main paper
left = vote_sp %>% filter(type != "Voted PP, dx" & 
                             mod=="ebal" & 
                             treat=="treat_2day") %>% left_plot()
right = vote_sp %>% filter(type == "Voted PP, dx"& 
                             mod=="ebal" & 
                             treat=="treat_2day") %>% right_plot()
final=final_plot(left,right) 


title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "Two day treatment window, entropy balance matching specification")

ggsave(here("fig4_vote_main.png"),final, width=9, height=6)
```

#### Regression Results


```{r, echo=FALSE, fig.align='center'}
knitr::include_graphics("sp_vote.PNG")
```



### Alternative Specifications

#### Bivariate Regression of Outcome on Treatment Indicator (No Matching)

```{r spainvote-figs-biv, cache=TRUE}
# Alternative spec: Simple regression, no balancing
left = vote_sp %>% filter(type != "Voted PP, dx" & 
                             mod=="biv" & 
                             treat=="treat_2day") %>% left_plot()
right = vote_sp %>% filter(type == "Voted PP, dx"& 
                             mod=="biv" & 
                             treat=="treat_2day") %>% right_plot()
final=final_plot(left,right) 


title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "Two day treatment window, bivariate specification")

ggsave(here("fig4A_vote_biv.png"),final, width=8, height=4)
```

#### One Day Sample Bandwith (Not Two Days)

```{r spainvote-figs-one, cache=TRUE}
# Alternative spec: One day bandwidth
left = vote_sp %>% filter(type != "Voted PP, dx" & 
                             mod=="ebal" & 
                             treat=="treat_1day") %>% left_plot()
right = vote_sp %>% filter(type == "Voted PP, dx"& 
                             mod=="ebal" & 
                             treat=="treat_1day") %>% right_plot()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One day treatment window, entropy balance matching specification")
ggsave(here("fig4A_vote_one.png"), final,width=8, height=4)
```

#### Full Sample Bandwith (Not Two Days)

```{r spainvote-figs-full, cache=TRUE}

# Alternative spec: Full sample bandwidth
left = vote_sp %>% filter(type != "Voted PP, dx" & 
                             mod=="ebal" & 
                             treat=="treat_full") %>% left_plot()
right = vote_sp %>% filter(type == "Voted PP, dx"& 
                             mod=="ebal" & 
                             treat=="treat_full") %>% right_plot()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "Full sample treatment window, entropy balance matching specification")


ggsave(here("fig4A_vote_full.png"), final,width=8, height=4)
```


#### Regression of Outcome on Treatment Indicator and Political Sophistication Moderator (Two Days)

```{r spain_moderation, cache=TRUE}


left_plot_solo3 <- function (p) {
  ggplot(p) + 
    aes(x = dv_name, y = est, color=type_name,shape=type_name) + 
    geom_hline(yintercept=0, colour="gray40") +
    geom_errorbar(aes(ymin=est-1.645*se, ymax=est+1.645*se), size=1,
                  width=0,position=position_dodge(width = 0.5)) +
    geom_errorbar(aes(ymin=est-1.96*se, ymax=est+1.96*se), 
                  width=0,position=position_dodge(width = 0.5)) + 
    geom_point(size = 3,position=position_dodge(width = 0.5)) +
    scale_y_continuous("") +
    scale_x_discrete("") +
    scale_color_brewer(palette="Set1")+
    expand_limits(y=c(-1,1))+
    theme(legend.title = element_blank(), legend.key = element_blank(),
          legend.position = 'bottom', legend.direction = 'horizontal',
          plot.margin = margin(2, 0, 10, 10))  +  
    theme(plot.margin = margin(0, 0, 5, 10)) +
    coord_flip() +  guides(col=guide_legend(nrow=2,byrow=TRUE)) 
}

sp_mod = dat_int %>% filter(dv %in% c("likelyvote_ciudadanos",
                                  "likelyvote_podemos",
                                  "likelyvote_psoe",
                                  "likelyvote_pp") &
                             type %in% c("Both ppvote and p14r 0",
                                         "Voted PP=0, p14r=1",
                                         "Voted PP=1, p14r=0",
                                         "Voted PP=1, p14r=1"))  %>% 
  mutate(      
    dv_name = case_when(
    dv == "likelyvote_ciudadanos" ~ "Ciudadanos,\n likely vote",
    dv == "likelyvote_podemos" ~ "Podemos,\n likely vote",
    dv == "likelyvote_pp" ~ "PP, likely vote",
    dv == "likelyvote_psoe" ~ "PSOE, likely vote"),
    type_name=case_when(
    type == "Both ppvote and p14r 0" ~ "Other respondents, low sophisticates",
    type == "Voted PP=1, p14r=0" ~ "PP voters, low sophisticates",
    type == "Voted PP=0, p14r=1" ~ "Other respondents, high sophisticates",
    type == "Voted PP=1, p14r=1" ~ "PP voters, high sophisticates"),
  type_name=fct_relevel(factor(type_name), 
                        "PP voters, low sophisticates", 
                        "PP voters, high sophisticates", 
                        "Other respondents, low sophisticates",
                        "Other respondents, high sophisticates"))

left = sp_mod %>% filter(treat=="treat_2day" & 
                              mod=="ebal")  %>% left_plot_solo3()


title_plot(left,"Average effects of treatment by subgroup",
           "Two day treatment window, entropy balance matching specification")

ggsave(here("fig4A_spain_moderated.png"),left, width=9, height=6)

```

\pagebreak

#### Voting Intentions in Spain: Alternative measure

```{r spainvote-sunday, cache=TRUE}
vote_sp2 = dat %>% filter(dv %in% c("vote_PSOE","vote_PP","vote_Ciudadanos","vote_Podemos"))

 vote_sp2 = vote_sp2 %>% mutate(      
             dv_name = case_when(
                dv == "vote_Ciudadanos" ~ "Vote Ciudadanos",
                dv == "vote_Podemos" ~ "Vote Podemos",
                dv == "vote_PP" ~ "Vote PP",
                dv == "vote_PSOE" ~ "Vote PSOE"),
          type_name=case_when(
                type == "Main" ~ "All respondents",
                type == "Voted PP, 1" ~ "Subsample:\nPP voters",
                type == "Voted PP, 0" ~ "Subsample:\nOther respondents",
                type == "Voted PP, dx" ~ "Marginal effect by party"),
            type_name=fct_relevel(factor(type_name), 
                                       "All respondents",
                                       "Subsample:\nPP voters",
                                       "Subsample:\nOther respondents"),
             panel=case_when(type=="Main" ~ "Average effects", 
                             type=="Voted PP, dx" ~ "Marginal differences by party",
                             TRUE ~ "Average effects"))
```


```{r spainvote-sunday-figs, cache=TRUE}

left = vote_sp2 %>% filter(type != "Voted PP, dx" & 
                             mod=="ebal" & 
                             treat=="treat_2day") %>% 
   left_plot() + scale_y_continuous("",limits=c(-0.25,0.25),
                                    labels=scales::percent_format(accuracy=1))

right = vote_sp2 %>% mutate(dv_name=factor(dv_name)) %>% 
   filter(type == "Voted PP, dx"& 
                             mod=="ebal" & 
                             treat=="treat_2day") %>% 
   right_plot() + 
   scale_x_discrete("",drop=FALSE) + 
   scale_y_continuous("",limits=c(-0.25,0.25),
                      labels=scales::percent_format(accuracy=1)) 

final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "Two day treatment window, bivariate specification")

ggsave(here("fig4A_vote_main.png"), final,width=8, height=4)


```

# Pseudo Manipulation Checks - Perceptions of Tax Compliance in France

We take advantage of two unique questions in the ISSP survey that serve as ``manipulation checks'', of sorts, of the treatment. Respondents provide their level of agreement with two statements: major private companies try to avoid paying taxes, and tax contributors are treated equally under the law by French tax authorities, regardless of their place in society. Since the Panama Papers mostly exposed wealthy individuals and politicians, not corporations, exposure to this treatment should decrease respondents' impression of (relative) tax avoidance among large firms. At the same time, the exposure highlighted how wealthy individuals tend to skirt tax obligations, which should decrease impressions that all tax contributors are treated equally.

```{r taxcomp, cache=TRUE}
mani_fr = dat %>% filter(dv %in% c("v55r","v57r") &
                            type %in% c("Main",
                                        "pol_sophistication_binary, 0",
                                        "pol_sophistication_binary, 1",
                                        "pol_sophistication_binary, dx"))

mani_fr = mani_fr %>% mutate(      
  dv_name = case_when(
    dv == "v55r" ~ "Tax contributors \n treated equally",
    dv == "v57r" ~ "Companies, try to \n avoid paying taxes"),
  type_name=case_when(
    type == "Main" ~ "All respondents",
    type == "pol_sophistication_binary, 1" ~ "Subsample: High sophistication",
    type == "pol_sophistication_binary, 0" ~ "Subsample: Low sophistication",
    type =="pol_sophistication_binary, dx" ~ "Marginal effect by sophistication"),
  panel=case_when(type=="Main" ~ "Average effects", #  "All respondents",
                  type=="pol_sophistication_binary, dx" ~ "Marginal differences by sophistication",
                  TRUE ~ "Average effects") # "Income subgroups"))
)
```

To begin with, the figure below displays the effects on the two items used to capture general exposure to the treatment. The results show that the treatment reduced perceptions of tax avoidance among large corporations, which were absent in the media revelations and subsequent scandals of the Panama Papers exposure. This effect is only significant among more politically sophisticated respondents, as would be expected assuming that sophistication proxies for exposure to political information in the media. 

```{r taxcomp-figs1, cache=TRUE}
# Figure in paper
left = mani_fr %>% filter(treat=="treat_1month" & 
                             mod=="ebal" &
                             type %in% c("Main",
                                        "pol_sophistication_binary, 0",
                                        "pol_sophistication_binary, 1")) %>% left_plot()
right = mani_fr %>% filter(treat=="treat_1month" &
                              mod=="ebal" &
                              type %in% c("pol_sophistication_binary, dx")) %>% right_plot()
final=final_plot(left,right) 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig1_mani_main.png"),final, width=9, height=6)
```

The other outcome also displays significant effects, albeit in the opposite direction of our prior expectation. The Panama Papers, along with the corruption and tax scandals that ensued in France, seemingly significantly increased the perception that all citizens are treated equally by French tax authorities, regardless of their standing in society. In light of our prior discussion it is difficult to rationalize this finding. As such, treating this as a ''manipulation check'', some caution is required in interpreting our results. At the very least, as we discuss in the main paper, it seems warranted to view the treatment of the Panama Papers disclosure in France, as seen from a one month window after the disclosures, as a compounded treatment, which includes both the original disclosures and the subsequent government reactions. 

As the analyses, the manipulation check results are fairly consistent across additional subgroup analyses and robustness tests. If anything, the results are stronger for high sophisticates, which is consistent with the interpretation of these results are indicating post-treatment shifts in beliefs as a result of the Panama Papers disclosures and the political reactions they unleashed in France.

## Regression Results

```{r, echo=FALSE, fig.align='center'}
knitr::include_graphics("fr_tax_main.PNG")
```


### Bivariate Regression of Manipulation Check Outcomes on Treatment Indicator (No Matching)

```{r taxcomp-figs-biv2}
# Alternative spec: Simple regression, no balancing k
left = mani_fr %>% filter(treat=="treat_1month" & 
                             mod=="biv" &
                             type %in% c("Main",
                                        "pol_sophistication_binary, 0",
                                        "pol_sophistication_binary, 1")) %>% left_plot()
right = mani_fr %>% filter(treat=="treat_1month" &
                              mod=="biv" &
                              type %in% c("pol_sophistication_binary, dx")) %>% right_plot()
final=final_plot(left,right) 
 

title_plot(final,"Average effects of treatment and marginal differences by subgroup",
           "One month treatment window, bivariate specification")

ggsave(here("fig1A_mani_biv.png"),final, width=9, height=6)
```



### Regression of Outcome on Treatment Indicator and Income Moderator 

```{r mani_moderation, cache=TRUE}

mani_fr2 = dat_int %>% filter(dv %in% c("v55r","v57r") &
                             type %in% c("polsop_top40, 0 both",
                                         "polsop_top40, 0 polsop, 1 other",
                                         "polsop_top40, 1 polsop, 0 other",
                                         "polsop_top40, 1 both"))  %>% 
  mutate(      
    dv_name = case_when(
      dv == "v55r" ~ "Tax contributors \n treated equally",
      dv == "v57r" ~ "Companies, try to \n avoid paying taxes"),
    type_name=case_when(
      type == "polsop_top40, 0 both" ~ "Bottom 60% income, low sophisticates",
      type == "polsop_top40, 0 polsop, 1 other" ~ "Top 40% income, low sophisticates",
      type == "polsop_top40, 1 polsop, 0 other" ~ "Bottom 60% income, high sophisticates",
      type == "polsop_top40, 1 both" ~ "Top 40% income, high sophisticates"))

left = mani_fr2 %>% filter(treat=="treat_1month" & 
                              mod=="ebal" &
                              type %in% c("polsop_top40, 0 both",
                                         "polsop_top40, 0 polsop, 1 other",
                                         "polsop_top40, 1 polsop, 0 other",
                                         "polsop_top40, 1 both")) %>% left_plot_solo()


title_plot(left,"Average effects of treatment by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig1A_mani_moderated.png"),left, width=8, height=4)

```

### Regression of Outcome on Treatment Indicator and Socialist Moderator 

```{r mani_moderation2, cache=TRUE}

mani_fr2 = dat_int %>% filter(dv %in% c("v55r","v57r") &
                             type %in% c("polsop_pr, 0 both",
                                         "polsop_pr, 0 polsop, 1 other",
                                         "polsop_pr, 1 polsop, 0 other",
                                         "polsop_pr, 1 both"))  %>% 
  mutate(      
    dv_name = case_when(
      dv == "v55r" ~ "Tax contributors \n treated equally",
      dv == "v57r" ~ "Companies, try to \n avoid paying taxes"),
    type_name=case_when(
    type == "polsop_pr, 0 both" ~ "Other respondents, low sophisticates",
    type == "polsop_pr, 0 polsop, 1 other" ~ "Socialist voters, low sophisticates",
    type == "polsop_pr, 1 polsop, 0 other" ~ "Other respondents, high sophisticates",
    type == "polsop_pr, 1 both" ~ "Socialist voters, high sophisticates"),
      type_name=fct_relevel(factor(type_name), 
                        "Socialist voters, high sophisticates", 
                        "Socialist voters, low sophisticates", 
                        "Other respondents, high sophisticates",
                        "Other respondents, low sophisticates"))

left = mani_fr2 %>% filter(treat=="treat_1month" & 
                              mod=="ebal" &
                            type %in% c("polsop_pr, 0 both",
                                         "polsop_pr, 0 polsop, 1 other",
                                         "polsop_pr, 1 polsop, 0 other",
                                         "polsop_pr, 1 both")) %>% left_plot_solo()


title_plot(left,"Average effects of treatment by subgroup",
           "One month treatment window, entropy balance matching specification")

ggsave(here("fig1A_mani_moderated2.png"),left, width=8, height=4)
```




